#ifndef CANVAS_H
#define CANVAS_H

#include <QGLWidget>

class Control;
class Snake;

class Canvas : public QGLWidget
{
public:
    Canvas(QWidget* parent=0);
    void setControl(Control* c);
    void setSnake(Snake* s);
    void setWall(QRect w);
    void setDimensions(int w, int h);
    void setEat(int x, int y);
    void setPaused(bool p);
    void keyPressEvent(QKeyEvent *e);
    void paintGL();

private:
    QPoint eat;
    QRect wall;
    Control* control;
    Snake* snake;
    int cellLenght;
    int gw, gh;
    bool paused;

    void drawBackground();
    void drawPoint(QPainter& painter, QPoint p, QColor color);
    void drawScreen(QPainter& painter);
    void drawSnake(QPainter& painter);
    void drawEat(QPainter& painter);
};

#endif // CANVAS_H
